import { Injectable } from '@angular/core';
import { UserService } from '../../service/user.service';
import { UtilsService } from '../../service/utils.service';
import { BaseService } from '../../service/base.service';
import { HttpPcSerice } from '../../service/https.pc.sercice ';
import { HttpSerice } from '../../service/https.sercice';
import { HttpsObService } from 'src/app/service/https.ob.service';
@Injectable({
  providedIn: 'root',
})
export class YearawardService {
  public activityDate: any;
  public rankactivityDate: any;
  public matchStartDate: any;
  public matchEndDate: any;
  public endDate: any;
  public startType: any;
  constructor(
    private http: HttpSerice,
    private userService: UserService,
    private httppcService: HttpPcSerice,
    private UtilsService: UtilsService,
    private BaseService: BaseService,
    private httpsObService: HttpsObService
  ) {}
  public setStartType(startType: any): void {
    this.startType = startType;
  }
  public getStartType(): any {
    return this.startType;
  }
  public setActivityDate(activityDate: any): void {
    this.activityDate = activityDate;
  }
  public getActivityDate(): any {
    return this.activityDate;
  }
  public setEndDate(endDate: any): void {
    this.endDate = endDate;
  }
  public getEndDate(): any {
    return this.endDate;
  }
  public setRankStartDate(rankactivityDate: any): void {
    this.rankactivityDate = rankactivityDate;
  }
  public getRankStartDate(): any {
    return this.rankactivityDate;
  }
  public setMatchStartDate(matchStartDate: any): void {
    this.matchStartDate = matchStartDate;
  }
  public getMatchStartDate(): any {
    return this.matchStartDate;
  }
  public setMatchEndDate(matchEndDate: any): void {
    this.matchEndDate = matchEndDate;
  }
  public getMatchEndDate(): any {
    return this.matchEndDate;
  }
  /**
   *  获取用户贡献榜
   * @param suc
   * @param activityType 活动类型(490-感恩节之日榜争夺第一轮、493-感恩节之日榜争夺第二轮、496-感恩节之日榜争夺第三轮)
   * @param pageSize
   * @param err
   */
  public getUserRanking(
    suc: any,
    activityType: number,
    pageSize: number,
    err: any
  ) {
    if (this.userService.getIsPc()) {
      let url =
        this.httppcService.baseUrl +
        'activity/ranking/user?activityType=' +
        activityType +
        '&pageSize=' +
        pageSize;
      this.httppcService.httpGet(url, suc, err);
    } else {
      let url =
        this.http.baseUrl +
        'activity/ranking/user?activityType=' +
        activityType +
        '&pageSize=' +
        pageSize;
      this.http.httpGet(url, suc, err);
    }
  }
  public getUserRankingV2(params: Record<string, any>) {
    return this.httpsObService.get(`activity/ranking/user`, params);
  }
  /**
   *  获取用户贡献榜
   * @param suc
   * @param activityType 活动类型(490-感恩节之日榜争夺第一轮、493-感恩节之日榜争夺第二轮、496-感恩节之日榜争夺第三轮)
   * @param pageSize
   * @param err
   */
  public getUserstageRanking(
    suc: any,
    activityType: number,
    pageSize: number,
    err: any
  ) {
    if (this.userService.getIsPc()) {
      let url =
        this.httppcService.baseUrl +
        'activity/ranking/user/stage?stageId=' +
        activityType +
        '&pageSize=' +
        pageSize;
      this.httppcService.httpGet(url, suc, err);
    } else {
      let url =
        this.http.baseUrl +
        'activity/ranking/user/stage?stageId=' +
        activityType +
        '&pageSize=' +
        pageSize;
      this.http.httpGet(url, suc, err);
    }
  }
  /**
   * 获取用户贡献榜当前用户
   * @param suc
   * @param err
   */
  public getCurrentUserRanking(suc: any, activityType: number, err: any) {
    if (this.userService.getIsPc()) {
      let url =
        this.httppcService.baseUrl +
        'activity/ranking/current-user?activityType=' +
        activityType +
        '&uid=' +
        this.BaseService.getUserid();
      this.httppcService.httpGet(url, suc, err);
    } else {
      let url =
        this.http.baseUrl +
        'activity/ranking/current-user?activityType=' +
        activityType +
        '&token=' +
        this.BaseService.getUserToken() +
        '&uid=' +
        this.BaseService.getUserid();
      this.http.httpGet(url, suc, err);
    }
  }
  /**
   * 获取用户贡献榜当前用户
   * @param suc
   * @param err
   */
  public getCurrentstageUserRanking(suc: any, activityType: number, err: any) {
    if (this.userService.getIsPc()) {
      let url =
        this.httppcService.baseUrl +
        'activity/ranking/current-user/stage?stageId=' +
        activityType +
        '&uid=' +
        this.BaseService.getUserid();
      this.httppcService.httpGet(url, suc, err);
    } else {
      let url =
        this.http.baseUrl +
        'activity/ranking/current-user/stage?stageId=' +
        activityType +
        '&token=' +
        this.BaseService.getUserToken() +
        '&uid=' +
        this.BaseService.getUserid();
      this.http.httpGet(url, suc, err);
    }
  }

  /**
   * 获取主播榜单
   * @param suc
   * @param stageId
   * @param pageSize
   * @param err
   */
  public getActivityRanking(
    suc: any,
    stageId: any,
    pageSize: number,
    err: any
  ) {
    if (this.userService.getIsPc()) {
      let url =
        this.httppcService.baseUrl +
        'activity/ranking/anchor/stage?stageId=' +
        stageId +
        '&pageSize=' +
        pageSize;
      this.httppcService.httpGet(url, suc, err);
    } else {
      let url =
        this.http.baseUrl +
        'activity/ranking/anchor/stage?stageId=' +
        stageId +
        '&pageSize=' +
        pageSize;
      this.http.httpGet(url, suc, err);
    }
  }
  /**
   * 获取真爱榜主播
   * @param suc
   * @param anchorUid
   * @param stageId
   * @param pageSize
   * @param err
   */
  public getActivityRankingTrueLove(
    suc: any,
    anchorUid: any,
    stageId: any,
    pageSize: number,
    err: any
  ) {
    if (this.userService.getIsPc()) {
      let url =
        this.httppcService.baseUrl +
        'activity/love/list?anchorUid=' +
        anchorUid +
        '&activityStageId=' +
        stageId +
        '&pageSize=' +
        pageSize;
      this.httppcService.httpGet(url, suc, err);
    } else {
      let url =
        this.http.baseUrl +
        'activity/love/list?anchorUid=' +
        anchorUid +
        '&activityStageId=' +
        stageId +
        '&pageSize=' +
        pageSize;
      this.http.httpGet(url, suc, err);
    }
  }

  /**
   * @param suc
   * @param uid
   * @param pageSize
   * @param err
   * @description: 获取每日任务
   */
  public getDailyTask(suc: any, uid: any, err: any) {
    //pre.91banban.com/zbapp/activity/valentine/queryTaskCompletion?uid=91563
    if (this.userService.getIsPc()) {
      const url = `${this.httppcService.baseUrl}activity/valentine/queryTaskCompletion?uid=${uid}`;
      this.httppcService.httpGet(url, suc, err);
    } else {
      const url = `${this.http.baseUrl}activity/valentine/queryTaskCompletion?uid=${uid}`;
      this.httppcService.httpGet(url, suc, err);

      this.http.httpGet(url, suc, err);
    }
  }

  /**
   * 获取当前主播信息
   * @param suc
   * @param uid 主播ID
   * @param err
   */
  public getCurrentAnchorRanking(
    suc: any,
    uid: string,
    stageId: number,
    err: any
  ) {
    if (this.userService.getIsPc()) {
      let url =
        this.httppcService.baseUrl +
        'activity/ranking/current-anchor/stage?uid=' +
        uid +
        '&stageId=' +
        stageId;
      this.httppcService.httpGet(url, suc, err);
    } else {
      let url =
        this.http.baseUrl +
        'activity/ranking/current-anchor/stage?uid=' +
        uid +
        '&stageId=' +
        stageId;
      this.http.httpGet(url, suc, err);
    }
  }

  //获取活动配置
  public getConfigs(suc: any, err: any) {
    if (this.userService.getIsPc()) {
      let url = this.httppcService.baseUrl + 'activity/configs';
      this.httppcService.httpGet(url, suc, err);
    } else {
      let url = this.http.baseUrl + 'activity/configs';
      this.http.httpGet(url, suc, err);
    }
  }

  /**
   * 获取任意主播直播间
   */
  public getAnchorroom(suc: any, err: any) {
    if (this.userService.getIsPc()) {
      const url =
        this.httppcService.baseUrl + 'activity/valentine/getAnyBeautifulAnchor';
      this.httppcService.httpGet(url, suc, err);
    } else {
      const url =
        this.http.baseUrl + 'activity/valentine/getAnyBeautifulAnchor';
      this.http.httpGet(url, suc, err);
    }
  }

  /**
   * 五周年庆-查询用户已签到次数
   * @param suc：回调
   * @param stageId：阶段id
   * @param err：回调
   */
  public userManualSignInDetails(suc: any, err: any) {
    if (this.userService.getIsPc()) {
      const url =
        this.httppcService.baseUrl +
        'activity/anniversary/userManualSignInDetails?token=' +
        this.BaseService.getUserToken();
      return this.httppcService.httpPost(url, {}, suc, err);
    } else {
      const url =
        this.http.baseUrl +
        'activity/anniversary/userManualSignInDetails?token=' +
        this.BaseService.getUserToken();
      const postjson = {};
      this.http.httpPost(url, postjson, suc, err);
    }
  }
  /**
   * 五周年庆-用户手动签到任务
   * @param suc：回调
   * @param stageId：阶段id
   * @param err：回调
   */
  public userManualSignInTask(suc: any, err: any) {
    if (this.userService.getIsPc()) {
      const url =
        this.httppcService.baseUrl +
        'activity/anniversary/userManualSignInTask?token=' +
        this.BaseService.getUserToken();
      return this.httppcService.httpPost(url, {}, suc, err);
    } else {
      const url =
        this.http.baseUrl +
        'activity/anniversary/userManualSignInTask?token=' +
        this.BaseService.getUserToken();
      const postjson = {};
      this.http.httpPost(url, postjson, suc, err);
    }
  }

  /**
   * 获取冠军奖池
   * @param suc
   * @param err
   */
  public championPool(suc: any, err: any) {
    if (this.userService.getIsPc()) {
      const url =
        this.httppcService.baseUrl +
        'pk/peak/champion/pool?token=' +
        this.BaseService.getUserToken();
      this.httppcService.httpGet(url, suc, err);
    } else {
      const url =
        this.http.baseUrl +
        'pk/peak/champion/pool?token=' +
        this.BaseService.getUserToken();
      this.http.httpGetParm(url, suc, err);
    }
  }
  /**
   * 获取直通赛吃鸡榜单
   * @param suc
   * @param err
   */
  public pkFinalsRank(suc: any, roomId: string, round: number, err: any) {
    if (this.userService.getIsPc()) {
      const url =
        this.httppcService.baseUrl +
        'pk/peak/finals/rank?token=' +
        this.BaseService.getUserToken() +
        '&roomId=' +
        roomId +
        '&round=' +
        round;
      this.httppcService.httpGet(url, suc, err);
    } else {
      const url =
        this.http.baseUrl +
        'pk/peak/finals/rank?token=' +
        this.BaseService.getUserToken() +
        '&roomId=' +
        roomId +
        '&round=' +
        round;
      this.http.httpGetParm(url, suc, err);
    }
  }
  /**
   *  加时赛榜单
   * @param suc
   * @param err
   */
  public overtimeRank(suc: any, roomId: string, round: number, err: any) {
    if (this.userService.getIsPc()) {
      const url =
        this.httppcService.baseUrl +
        'pk/peak/overtime/rank?token=' +
        this.BaseService.getUserToken() + '&roomId=' + roomId;
      this.httppcService.httpGet(url, suc, err);
    } else {
      const url =
        this.http.baseUrl +
        'pk/peak/overtime/rank?token=' +
        this.BaseService.getUserToken() + '&roomId=' + roomId;
      this.http.httpGetParm(url, suc, err);
    }
  }

  /**
   * 获取公共奖池魅力金额
   * @param suc
   * @param err
   */
  public getJackpotBaseValues(suc: any, err: any) {
    if (this.userService.getIsPc()) {
      const url =
        this.httppcService.baseUrl + 'activity/endyear/getJackpotBaseValues';
      this.httppcService.httpGet(url, suc, err);
    } else {
      const url = this.http.baseUrl + 'activity/endyear/getJackpotBaseValues';
      this.http.httpGet(url, suc, err);
    }
  }

  /**
   *  荣誉盛典列表
   * @param suc
   * @param err
   */
  public getRongyuList(suc: any, err: any) {
    if (this.userService.getIsPc()) {
      const url =
        this.httppcService.baseUrl + 'activity/endyear/throughAnchors';
      this.httppcService.httpGet(url, suc, err);
    } else {
      const url = this.http.baseUrl + 'activity/endyear/throughAnchors';
      this.http.httpGet(url, suc, err);
    }
  }

  /**
   * @param suc
   * @param err
   * @description: 访问活动页面
   */
  public visitActivityPage(suc: any, err: any) {
    if (this.userService.getIsPc()) {
      const url =
        this.httppcService.baseUrl +
        'activity/valentine/visitActivityPage?uid=' +
        this.BaseService.getUserid();
      this.httppcService.httpGet(url, suc, err);
    } else {
      const url =
        this.http.baseUrl +
        'activity/valentine/visitActivityPage?uid=' +
        this.BaseService.getUserid();
      this.http.httpGet(url, suc, err);
    }
  }

  //
  /**
   * @param suc
   * @param err
   * @description: 签到福利 - 立即签到
   */
  public sign(suc: any, err: any) {
    if (this.userService.getIsPc()) {
      const url =
        this.httppcService.baseUrl +
        'activity/nationaldaytour/signIn?token=' +
        this.BaseService.getUserToken();

      this.httppcService.httpPost(url, {}, suc, err);
    } else {
      const url =
        this.http.baseUrl +
        'activity/nationaldaytour/signIn?token=' +
        this.BaseService.getUserToken();
      this.http.httpPost(url, {}, suc, err);
    }
  }
  // https://pre.91banban.com/zbapp/activity/monster/getUserNewSpringDetail?token=OTE1NjNfRDk2MzdDOERBRkVBMDc3MzdBMjM3NTc5QjI0NTIzRTZfMl9GOTc0QTcwQy1CMDM4LTQwQzMtQjlGOC1ENDc3MDc3MTUzMDNfMTY2OTE3MDg0OV9iYW5iYW4xMjM0NTY=

  /**
   * @param suc
   * @param err
   * @description: 签到福利 - 获取签到详情
   */
  public getSignDetail(suc: any, err: any) {
    if (this.userService.getIsPc()) {
      const url =
        this.httppcService.baseUrl +
        'activity/monster/getUserNewSpringDetail?token=' +
        this.BaseService.getUserToken();
      this.httppcService.httpGet(url, suc, err);
    } else {
      const url =
        this.http.baseUrl +
        'activity/monster/getUserNewSpringDetail?token=' +
        this.BaseService.getUserToken();
      this.http.httpGet(url, suc, err);
    }
  }

  // activity/carnival/queryInRoomWatchTime?uid=91563

  /**
   * @param suc
   * @param err
   * @description: 签到福利 - 获取签到详情
   */
  public getUserWatchTime(suc: any, err: any, uid) {
    if (this.userService.getIsPc()) {
      const url =
        this.httppcService.baseUrl +
        'activity/carnival/queryInRoomWatchTime?uid=' +
        uid;
      this.httppcService.httpGet(url, suc, err);
    } else {
      const url =
        this.http.baseUrl + 'activity/carnival/queryInRoomWatchTime?uid=' + uid;
      this.http.httpGet(url, suc, err);
    }
  }
  /**
   * @param suc
   * @param err
   * @param type 0主播 1用户
   * @description:
   */
  public getAnchorUserScore(suc: any, err: any, type: 0 | 1) {
    const uid = this.BaseService.getUserid();
    if (this.userService.getIsPc()) {
      const url =
        this.httppcService.baseUrl +
        '/activity/yearmid/getAnchorOrUserScore?uid=' +
        uid +
        '&type=' +
        type;
      this.httppcService.httpGet(url, suc, err);
    } else {
      const url =
        this.http.baseUrl +
        '/activity/yearmid/getAnchorOrUserScore?uid=' +
        uid +
        '&type=' +
        type;
      this.http.httpGet(url, suc, err);
    }
  }
  public getImInfo(suc: any, err: any) {
    if (this.userService.getIsPc()) {
      const url = this.httppcService.baseUrl + 'activity/summer/night/ryInfo?uid=' + this.BaseService.getUserid();
      this.httppcService.httpGet(url, suc, err);
    } else {
      const url = this.http.baseUrl + 'activity/summer/night/ryInfo?uid=' + this.BaseService.getUserid();
      this.http.httpGetParm(url, suc, err);
    }
  }
}
